Skip to content

Adds ability to declare type on "For Each" loop item#1614

Merged
TwitchBronBron merged 5 commits intov1from
for_loop_item_type
Jan 28, 2026
Merged

Adds ability to declare type on "For Each" loop item#1614
TwitchBronBron merged 5 commits intov1from
for_loop_item_type

Conversation

@markwpearce
Copy link
Collaborator

@markwpearce markwpearce commented Jan 27, 2026

  • Update parser to allow syntax like:
for each item as string in myList
   
end for
  • Convert for loop body to use a pocket table, to allow proper typing of loop item, so it is properly defined as Union of UnintializedType or

  • Add "assignment type mismatch" diagnostic for when the decalred type is not compatible with the inferred type of the array loop item. eg:

for each item as string in [1, 2, 3]
  • Adds validation on doing a for-each on a non-iterable type
  • Default iterable type of built-in iterable types are honored: roByteArray -> integer and roAssociativeArray-> string:
for each b in createObject("roByteArray").fromHexString("00FF1001")
   print b ' b is an integer
end for

for each key in {name: "John", age: 42}
  print key ' key is a string
end for

@markwpearce markwpearce added this to the v1.0.0 milestone Jan 27, 2026
@markwpearce markwpearce changed the base branch from master to v1 January 27, 2026 14:42
@markwpearce markwpearce marked this pull request as ready for review January 28, 2026 15:52
@TwitchBronBron TwitchBronBron merged commit b70f479 into v1 Jan 28, 2026
8 checks passed
@TwitchBronBron TwitchBronBron deleted the for_loop_item_type branch January 28, 2026 18:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants